package com.xy.tianyu.module.novel.adapter

import android.widget.LinearLayout
import androidx.core.content.ContextCompat
import com.blankj.utilcode.util.ScreenUtils
import com.blankj.utilcode.util.SizeUtils
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.xy.tianyu.R
import com.xy.tianyu.module.novel.bean.X
import com.xy.tianyu.utils.GlideUtils
import kotlinx.android.synthetic.main.item_competitive_recommend_child_vertical.view.*

/**
 * @time 2020/11/26 17:21
 * @class 描述:
 */
class CompetitiveRecommendChildVerAdapter(layoutResId: Int,data:MutableList<X>?):BaseQuickAdapter<X,BaseViewHolder>(layoutResId,data) {
    override fun convert(holder: BaseViewHolder, item: X) {

        with(holder.itemView){
            val layoutParams = iv_novel_cover_ver.layoutParams
            layoutParams.width = (ScreenUtils.getScreenWidth() - SizeUtils.dp2px(30f)) / 4
            layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT
            iv_novel_cover_ver.layoutParams = layoutParams

            Glide.with(context).load(item.cover).apply(GlideUtils.getRequestOptions()).into(iv_novel_cover_ver)
            tv_novel_title_ver.text = item.newBookName
            tv_novel_des_intro.text = item.intro
            tv_novel_author_ver.text = item.authorName
            tv_novel_score_ver.text = item.grade
            if (item.bookStatue == "01"){
                //连载
                tv_novel_status_ver.text = context.getString(R.string.ty_book_status_one)
                tv_novel_status_ver.setTextColor(ContextCompat.getColor(context,R.color.app_color_FFA428))
            }else{
                //完结
                tv_novel_status_ver.text = context.getString(R.string.ty_book_status_two)
                tv_novel_status_ver.setTextColor(ContextCompat.getColor(context,R.color.blueColor))
            }

            tv_novel_text_num_ver.text = item.wordCount
        }

    }
}